Release 10.1A: OpenEdge Development:
Progress 4GL Reference
SET-SIZE statement
Manages memory associated with a MEMPTR variable. This includes allocating and associating a region of memory with an uninitialized MEMPTR variable, setting the size of a region allocated with a Windows dynamic link library (DLL) or UNIX shared library routine for a MEMPTR, and deallocating memory associated with a MEMPTR variable.
Note: Does not apply to SpeedScript programming.Syntax
memptr-varA reference to a variable defined as MEMPTR.
sizeAn integer expression that specifies the allocated byte size of the region pointed to by
Examplememptr-var.In the following example, the SET-SIZE statement allocates 8 bytes of memory, associates the memory with the
ElipRegionvariable, and then initializes the region with four SHORT (2-byte) values:
Notes
- If
memptr-varhas no memory allocated to it (is uninitialized), then the SET-SIZE statement allocates a memory region of the specified size.Caution: You must know and specify the exact size of the memory region returned by the DLL routine from the type of structure it allocates. An incorrect size can result in data loss.- If a MEMPTR variable is returned from a DLL or UNIX shared library routine that also allocates a memory region to it, then the SET-SIZE statement initializes the size of the existing region. Progress does not allocate a new region. This allows Progress to perform bounds checking on references to MEMPTR regions allocated outside Progress.
- If the specified size is 0, the SET-SIZE statement deallocates (frees) any memory associated with
memptr-var, making it available to reference a new memory region.- If the specified size is greater than 0 and
memptr-varis fully initialized (associated with a memory region of a specified size), the SET-SIZE statement has no effect and leavesmemptr-varunchanged.- After initializing a MEMPTR variable, you can obtain the address of (or pointer to) the region associated with the variable using the GET-POINTER-VALUE function. Use this to build structures that contain pointers to other structures, as required by some DLL or UNIX shared library routines.
- For more information on accessing DLL routines from Progress, see OpenEdge Development: Programming Interfaces .
See also
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |